<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>个人资料 - AI简历分析</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 40px; background-color: #f5f5f5; }
        .container { max-width: 600px; margin: 0 auto; background: white; padding: 30px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
        .profile-header { display: flex; align-items: center; margin-bottom: 30px; }
        .profile-avatar { width: 100px; height: 100px; border-radius: 50%; margin-right: 20px; object-fit: cover; }
        .profile-info { flex: 1; }
        .form-group { margin-bottom: 20px; }
        label { display: block; margin-bottom: 5px; font-weight: bold; }
        input[type="email"], input[type="password"] { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 5px; box-sizing: border-box; }
        .btn { padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; text-decoration: none; display: inline-block; }
        .btn-primary { background: #007bff; color: white; }
        .btn-secondary { background: #6c757d; color: white; }
        .avatar-upload { margin-top: 20px; }
    </style>
</head>
<body>
<div class="container">
    <div class="profile-header">
        <th:block th:if="${user.avatarUrl}">
            <img th:src="@{${user.avatarUrl}}" class="profile-avatar" alt="用户头像">
        </th:block>
        <th:block th:unless="${user.avatarUrl}">
            <div class="profile-avatar" style="background-color: #007bff; color: white; display: flex; align-items: center; justify-content: center; font-size: 36px; font-weight: bold;"
                 th:text="${user.email?.substring(0,1)?.toUpperCase()}"></div>
        </th:block>
        <div class="profile-info">
            <h1 th:text="${user.email}"></h1>
            <p>注册时间: <span th:text="${user.createdAt}"></span></p>
        </div>
    </div>

    <form th:action="@{/admin/users/save}" method="post">
        <input type="hidden" th:field="*{user.id}">

        <div class="form-group">
            <label for="email">邮箱</label>
            <input type="email" id="email" th:field="*{user.email}" required>
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" id="password" th:field="*{user.password}" required>
        </div>

        <div class="form-group">
            <button type="submit" class="btn btn-primary">保存</button>
            <a th:href="@{/admin/users}" class="btn btn-secondary">返回</a>
        </div>
    </form>

    <div class="avatar-upload">
        <h3>上传头像</h3>
        <form th:action="@{/admin/profile/avatar}" method="post" enctype="multipart/form-data">
            <input type="file" name="avatar" accept="image/*" required>
            <button type="submit" class="btn btn-primary">上传</button>
        </form>
    </div>
</div>
</body>
</html>